/** *******************************************************************
 * FlexDatabaseManager
 * Copyright (c) 2008 Jonnie Spratley. All Rights Reserved.
 * @author  Jonnie Spratley
 * @contact jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.flexdatabasemanager.commands.tables
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.commands.SequenceCommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.jonniespratley.flexdatabasemanager.events.tables.GetTableDataEvent;
	import com.jonniespratley.flexdatabasemanager.events.tables.SelectedTableEvent;
	import com.jonniespratley.flexdatabasemanager.model.ModelLocator;
	import com.jonniespratley.flexdatabasemanager.vo.*;

	public class SelectedTableCommand extends SequenceCommand implements ICommand
	{
		private var model:ModelLocator = ModelLocator.getInstance();

		override public function execute( event:CairngormEvent ) : void
		{
			var evt:SelectedTableEvent = event as SelectedTableEvent;
	
			//set the selected table on the model	
			model.selectedTable = evt.aTable;
			
			
			//trigger the next event in sequence
			nextEvent = evt.nextEventSequence;
			GetTableDataEvent( nextEvent );
			executeNextCommand();
			trace( 'Sequence Event: Calling on GetTableDataEvent' );
		}
	}
}